
    <!-- 项目管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">团购商品</p>
    <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
    ></dxtable>
  </div>
</template>
<script lang='ts' setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost } from "../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive } from "vue";
const databale = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
let dataJson = [
  {
    title: "商品名称",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "title",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "轮播图",
    type: "imglist",
    key: "banner",
    width: "",
    render(row) {
      try {
        row.banner = row.banner.split(",");
      } catch (e) {}
      try {
        row.shangpingxq = row.shangpingxq.split(",");
      } catch (e) {}
    },
  },
  {
    title: "参考价",
    type: "number",
    val: "",
    icon: "dx-Field-number",
    span: 9,
    key: "chankaojia",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "折扣价",
    type: "number",
    val: "",
    icon: "dx-Field-number",
    span: 9,
    key: "zhekou",
    width: "80",
    search: false,
    istable: true,
    required: false,
    render(row) {
      return h(NTag, { type: "success" }, row.zhekou + "折");
    },
  },
  {
    title: "现价",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 6,
    key: "xianjia",
    width: "",
    search: false,
    istable: true,
    required: false,
  },

  {
    title: "累计销量",
    key: "",
    width: 80,
    render(h) {
      return 0;
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

let qx = {
  DeletePermissionID: "23456", //删除
  EditPermissionIdentifier: "meirongspguanlibj", // 编辑
  NewPermissionIdentifier: "23456", // 新建
  ViewPermissionID: "meirongspguanlick", // 查看
};
let portUrl = "meirong/tuango/tuango?zzhn="+localStorage.Userid;
if (localStorage.id == 92) {
  portUrl = "meirong/tuango/tuango?uid=" + localStorage.Userid;
  qx = {
  DeletePermissionID: "meirongspguanlidel", //删除
  EditPermissionIdentifier: "meirongspguanlibj", // 编辑
  NewPermissionIdentifier: "meirongspguanlixz", // 新建
  ViewPermissionID: "meirongspguanlick", // 查看
};
}




let formJson = reactive([
  {
    title: "商品名称",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "title",
    width: "",
    search: false,
    istable: true,
    required: true,
  },
  {
    title: "参考价",
    type: "number",
    val: "",
    icon: "dx-Field-number",
    span: 9,
    key: "chankaojia",
    width: "",
    search: false,
    istable: true,
    required: true,
    callBack: (data, model) => {
      console.log(data);
      model.xianjia = (data * (model.zhekou / 10)).toFixed(2);
    },
  },
  {
    title: "折扣价",
    type: "number",
    val: "",
    icon: "dx-Field-number",
    span: 9,
    key: "zhekou",
    width: "",
    search: false,
    istable: true,
    required: true,
    callBack: (data, model) => {
      console.log(data);
      model.xianjia = (model.chankaojia * (data / 10)).toFixed(2);
    },
  },
  {
    title: "现价",
    type: "label",
    val: "--",
    icon: "dx-shurukuang",
    span: 6,
    key: "xianjia",
    width: "",
    search: false,
    istable: true,
  },

  {
    title: "轮播图",
    type: "imglist",
    val: [],
    icon: "dx-ai-img-list",
    span: 24,
    key: "banner",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "商品详情",
    type: "imglist",
    val: [],
    icon: "dx-ai-img-list",
    span: 24,
    key: "shangpingxq",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "套餐内容",
    type: "textarea",
    val: "",
    icon: "dx-duohangwenben",
    span: 24,
    key: "taocnr",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "uid",
    type: "",
    val: localStorage.Userid,
    key: "uid",
  },
  {
    title: "购买须知",
    type: "textarea",
    val: "",
    icon: "dx-duohangwenben",
    span: 24,
    key: "goumaixuzhi",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "uid",
    type: "",
    val: localStorage.Userid,
    key: "uid",
  },
  {
    title: "",
    val: localStorage.zzhn,
    key: "zzhn",
  },
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {},
        },
        "复制代码"
      ),
    ];
  },
};

// 获取字典内容
// const xtgxxmfl = async () => {
//   const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'xtgxxmfl' })
//   dataJson[2].options = [
//     {
//       label: "全部",
//       value: ""
//     },
//     ...data
//   ]
//   formJson[2].options = data
//   xmlxSelect.value = data
//   console.log(data);
// }
// xtgxxmfl()
</script>
<style scoped></style>
    